home *** CD-ROM | disk | FTP | other *** search
/ Programming a Multiplayer FPS in DirectX / Programming a Multiplayer FPS in DirectX (Companion CD).iso / DirectX / dxsdk_oct2004.exe / dxsdk.exe / Samples / Media / UI / Default.fx < prev    next >
Encoding:
Text File  |  2004-09-27  |  3.7 KB  |  130 lines

  1. //
  2. // Default effect
  3. // Single texture
  4. // Copyright (c) 2000 Microsoft Corporation. All rights reserved.
  5. //
  6.  
  7. texture Texture0 < string Name = ""; >;
  8.  
  9. float4 Ambient : Ambient 
  10.     string Object = "Geometry"; 
  11. > = float4( 0.4f, 0.4f, 0.4f, 1.0f );
  12.    
  13. float4 Diffuse : Diffuse
  14.     string Object = "Geometry"; 
  15. > = float4( 0.6f, 0.6f, 0.6f, 1.0f );    
  16.  
  17. float4 Specular : Specular
  18.     string Object = "Geometry"; 
  19. > = float4( 1.0f, 1.0f, 1.0f, 1.0f );
  20.  
  21. float4 Emissive : Emissive
  22. <
  23.     string Object = "Geometry"; 
  24. > = float4( 0.0f, 0.0f, 0.0f, 1.0f ); 
  25.  
  26. float  Power : SpecularPower
  27.     string Object = "Geometry"; 
  28. > = 4;
  29.  
  30. float4 g_vLightColor : Diffuse
  31.     string Object = "Light0"; 
  32. > = float4( 1.0f, 1.0f, 1.0f, 1.0f );
  33.  
  34. float4 g_vLightDirection: Direction
  35.     string Object = "Light0"; 
  36. > = float4( 0.5f, 0.75f, 1.0f, 1.0f );   
  37.  
  38. float4 g_vCameraPosition : Position
  39.     string Object = "Camera"; 
  40. > = float4( 0.0f, 0.0f, 0.0f, 1.0f ); 
  41.             
  42. float4x4 g_mWorld : World;           // World matrix
  43. //float4x4 g_mView : View;             // View matrix
  44. //float4x4 g_mProjection : Projection; // Projection matrix
  45.  
  46. float4x4 g_mWorldViewProjection : WorldViewProjection; // World * View * Projection matrix
  47.  
  48.  
  49.  
  50. //--------------------------------------------------------------------------------------
  51. // Texture samplers
  52. //--------------------------------------------------------------------------------------
  53. sampler MeshTextureSampler = 
  54. sampler_state
  55. {
  56.     Texture = <Texture0>;    
  57.     MipFilter = LINEAR;
  58.     MinFilter = LINEAR;
  59.     MagFilter = LINEAR;
  60. };
  61.  
  62.  
  63. //--------------------------------------------------------------------------------------
  64. // Name: VS
  65. // Type: Vertex Shader
  66. // Desc: Projection transform
  67. //--------------------------------------------------------------------------------------
  68. void VS( float4 vPosObj: POSITION,
  69.          float3 vNormalObj: NORMAL,
  70.          float2 vTexCoordIn: TEXCOORD0,
  71.          out float4 vPosProj: POSITION,
  72.          out float4 vColorOut: COLOR0,
  73.          out float2 vTexCoordOut: TEXCOORD0
  74.         )
  75. {
  76.     // Transform the position into projected space for display and world space for lighting
  77.     vPosProj = mul( vPosObj, g_mWorldViewProjection ); 
  78.     //PosProj = mul( vPosObj, g_mWorld );
  79.     //vPosProj = mul( vPosProj, g_mView );
  80.     //vPosProj = mul( vPosProj, g_mProjection );
  81.    
  82.     
  83.     // Transform the normal into world space for lighting
  84.     float3 vNormalWorld = mul( vNormalObj, (float3x3)g_mWorld );
  85.     
  86.     // Compute ambient and diffuse lighting
  87.     vColorOut = g_vLightColor * Ambient;
  88.     vColorOut += g_vLightColor * Diffuse * saturate( dot( g_vLightDirection.xyz, vNormalWorld ) );
  89.    
  90.     // Pass the texture coordinate
  91.     vTexCoordOut = vTexCoordIn;
  92. }
  93.  
  94.  
  95.  
  96. //--------------------------------------------------------------------------------------
  97. // Name: PS
  98. // Type: Pixel Shader
  99. // Desc: Modulate the texture by the vertex color
  100. //--------------------------------------------------------------------------------------
  101. void PS( float4 vColorIn: COLOR0,
  102.                 float2 vTexCoord: TEXCOORD0,
  103.                 out float4 vColorOut: COLOR0 )
  104. {  
  105.     // Sample and modulate the texture
  106.     //float4 vTexColor = tex2D( MeshTextureSampler, vTexCoord );
  107.     //vColorOut = vColorIn * vTexColor;
  108.     vColorOut = vColorIn;
  109. }
  110.  
  111.  
  112. //--------------------------------------------------------------------------------------
  113. // Techniques
  114. //--------------------------------------------------------------------------------------
  115. technique T0
  116. {
  117.     pass P0
  118.     {
  119.         VertexShader = compile vs_1_1 VS();    
  120.         PixelShader = compile ps_1_1 PS();    
  121.     }
  122. }
  123.